package xyz.zdsoft.common.auth;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public class UserType {


    /**
     * 管理员标识
     */
    public static final UserType USER_TYPE_ADMIN = new UserType("admin", "管理员");

    /**
     * 老师标识
     */
    public static final UserType USER_TYPE_TEACHER = new UserType("teacher", "教师");

    /**
     * 学生标识
     */
    public static final UserType USER_TYPE_STUDENT = new UserType("student", "学生");
    /**
     * 所有用户标识
     */
    public static final UserType USER_TYPE_A_T_S = new UserType("a_t_s", "所有用户");
    /**
     * 管理员 教师
     */
    public static final UserType USER_TYPE_A_T = new UserType("a_t", "管理员和教师");
    /**
     * 教师 学生
     */
    public static final UserType USER_TYPE_T_S = new UserType("t_s", "教师和学生");
    /**
     * 管理员 学生
     */
    public static final UserType USER_TYPE_A_S = new UserType("a_s", "管理员和学生");

    public static boolean userAuthentication(String pathUserType,String sessionUserType){
        boolean isAuthentication = false;
        if(sessionUserType.equals(UserType.USER_TYPE_ADMIN.getName())){
            if(pathUserType.equals(UserType.USER_TYPE_A_T_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_A_T.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_A_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_ADMIN.getName())){
                isAuthentication = true;
            }
        }else if(sessionUserType.equals(UserType.USER_TYPE_TEACHER.getName())){
            if(pathUserType.equals(UserType.USER_TYPE_A_T_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_A_T.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_T_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_TEACHER.getName())){
                isAuthentication = true;
            }
        }else if(sessionUserType.equals(UserType.USER_TYPE_STUDENT.getName())){
            if(pathUserType.equals(UserType.USER_TYPE_A_T_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_A_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_T_S.getName())){
                isAuthentication = true;
            }else if(pathUserType.equals(UserType.USER_TYPE_STUDENT.getName())){
                isAuthentication = true;
            }
        }
        return isAuthentication;
    }
    private final String name;
    private final String format;

}
